package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppPingtaiHuodong;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 平台活动
 */
@Repository
public class AppPingtaiHuodongDao extends BaseDao<AppPingtaiHuodong> {

    /**
     * 查询列表
     */
    public List<AppPingtaiHuodong> findList(SplitPageBean splitPage) {
        ArrayList<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_pingtai_huodong where 1=1  ");
        sbStr.append(" and state = 1 ");
        sbStr.append(" order by createtime desc");
        String sql = sbStr.toString();
        return this.queryList(sql, paramList, AppPingtaiHuodong.class, splitPage);
    }

    /**
     * 详情
     */
    public AppPingtaiHuodong get(Integer id) {
        if (id == null || id <= 0) {
            return null;
        }
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_pingtai_huodong where id = ?  ");
        paramList.add(id);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, AppPingtaiHuodong.class);
    }

    /**
     * 获取最新的一条
     */
    public AppPingtaiHuodong getNew() {
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_pingtai_huodong where state=1 order by createtime desc limit 1 ");
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, AppPingtaiHuodong.class);
    }

}
